import React, { memo } from 'react';
import { Button, Spin, Table } from 'antd';
import AuthComponent from '@/utils/auth/AuthComponent';
import { history } from 'umi'

const TemplateTable = props => {
    const { onAdd, authCode = true, type, loading, ...tableProps } = props;
    const handleAdd = () => {
        history.push({
            pathname: '/office/personnelManagement/recruitment/setting/notice/employInfoAdd',
            query: { type },
            state: { tabRoute: true, tabRefresh: true }
        });
    };
    return (
        <Spin spinning={loading}>
            <div style={{ marginBottom: '24px' }}>
                <Table rowKey="id" pagination={false} {...tableProps} style={{ wordBreak: 'break-word' }} />
                <AuthComponent code={authCode}>
                    <Button type="dashed" icon="plus" block style={{ marginTop: 12 }} onClick={handleAdd}>
                        添加
                    </Button>
                </AuthComponent>
            </div>
        </Spin>
    );
};

export default memo(TemplateTable)
